﻿

//

using LaserMark.Models;
using LaserMark.View.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static LaserMark.Control.Service.mc;

namespace LaserMark.Extensions;
public static class CreateMockCrd
{
    public static Task<bool> Create(Original original, MarkOption option)
    {
        short sRtn;
        TCrdPrm crdPrm = new TCrdPrm();
        crdPrm.dimension = 2;
        crdPrm.synVelMax = 3000;
        crdPrm.synAccMax = 2;
        crdPrm.evenTime = 500;
        crdPrm.profile1 = 0;
        crdPrm.profile2 = 1;
        crdPrm.profile3 = 2;
        crdPrm.setOriginFlag = 1;
        crdPrm.originPos1 = 0;
        crdPrm.originPos2 = 0;
        crdPrm.originPos3 = 0;
        sRtn = GT_SetCrdPrm(0, 1, ref crdPrm);
        int space;
        sRtn = GT_CrdClear(0, 1, 0);
        var b = 1000 / (1 / option.XPluse.Value);
        foreach (var item in original.Points)
        {

            var xp = (item.X) / option.XPluse.Value;
            var yp = (item.Y) / option.YPluse.Value;

            var xp1 = (item.X1) / option.XPluse.Value;
            var yp1 = (item.Y1) / option.YPluse.Value;

            sRtn = GT_LnXY(0, 1, (int)xp, (int)yp, 100, option.MarkAcc.X / 10000, 0, 0);

            sRtn = GT_LnXY(0, 1, (int)xp1, (int)yp1, option.MarkVel.X / b, option.MarkAcc.X / 10000, 0, 0);
        }

        sRtn = GT_LnXY(0, 1, 0, 0, option.MarkVel.X / b, option.MarkAcc.X / 10000, 0, 0);
        sRtn = GT_CrdSpace(0, 1, out space, 0);
        sRtn = GT_CrdStart(0, 1, 0);
        return Task.FromResult(true);
    }
}
